// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require("base");
	var dialog = require("dialog");
	var validate = require("validate");
	var css_param = require("./createPickup4.css");
	var tools = require("tools");
	var databind = require("databind");
	var constant = require("constant");
    var html_bulkstockInfo = require("./html_bulkstockInfo.html");//查询货物弹出框内容
    var html_commonlyInfo = require("./html_commonlyInfo.html");
    var router = require("../hash/pageRouter");
	var html_verify = require("../apply/apply_verify.html");
	var html_bailReturn = require("./html_bailReturn.html");
	var html_cancelApplication = require("./html_cancelApplication.html");
    var ds;
	var productTypes;
    var enterpriseId;
    var financeNumber;
    var enterpriseName;
    var createPickups=6;
    var financeId;
    var financeState;
    var productType;
	var financeAmount;
    var pageIndex = 1,
		pageSize = 10,
		totalPageCount = 1,
		totalRecordCount = 0; //分页初始化
	var init = function(page) {
		enterpriseId = page.params.enterpriseId;
		financeNumber = page.params.financeNumber;
		enterpriseName = page.params.enterpriseName;
		productTypes = page.params.productType;
		financeId = page.params.financeId;
		$(".d2 a").removeClass("active_tab");
		$(".warehousePickups").addClass("active_tab");
		$(".accountDetail").parent().parent().addClass("active_tab4");
		$(".accountDetail").parent().parent().removeClass("active_tab1");
		$(".accountDetail").parent().parent().removeClass("active_tab2");
		$(".accountDetail").parent().parent().removeClass("active_tab3");
		
		tools.loadSelectList($("#createPickup4 select[name=enterpriseId]"), "inquireEnterpriseList.json", "id", "name", null);
		$("#createPickup4 select[name=enterpriseId]").val(enterpriseId);
		
		router.init();
//		inquireFinanceApplicationDetail();
		inquireFinanceApplicationDetail_s2();
		initEvent();
	};
		
		var initEvent = function() {
			
			$("#createPickup4 input[name=buyer]").val(enterpriseName);
			$("#createPickup4 input[name=productType]").val(productTypes);
			//发票类型点击事件
			$("#createPickup4 input[name=invoiceType]").unbind("click").click(function(){
				if ($(this).val() == "0") {
					$("#createPickup4 .invoiceInfo1").html("");
				} else if ($(this).val() == "1"){
					var str = '<div class="dataLine">				<div class="requireInput">					公司名称:<input type="text" isNull="1" codeName="公司名称" name="invoiceEnterpriseName" placeholder="请输入公司名称"/>				</div>				<div>				</div>			</div>			<div class="dataLine">				<div class="requireInput">					纳税识别号:<input type="text" isNull="1" codeName="纳税识别号" name="invoiceTaxpayerNumber" placeholder="请输入纳税识别号"/>				</div>				<div>				</div>			</div>			<div class="dataLine">				<div class="requireInput">					地址、电话:<input type="text" isNull="1" codeName="地址、电话" name="invoiceAddress" placeholder="请输入地址、电话"/>				</div>				<div>				</div>			</div>			<div class="dataLine">				<div class="requireInput">					开户行及账号:<input type="text" isNull="1" codeName="开户行及账号" name="invoiceAccount" placeholder="请输入开户行及账号"/>				</div>				<div>				</div>			</div>';
					$("#createPickup4 .invoiceInfo1").html(str);
				} else if ($(this).val() == "2") {
					var str = '<div class="dataLine">				<div class="requireInput">					公司名称:<input type="text" isNull="1" codeName="公司名称" name="invoiceEnterpriseName" placeholder="请输入公司名称"/>				</div>				<div>				</div>			</div>			<div class="dataLine">				<div class="requireInput">					纳税识别号:<input type="text" isNull="1" codeName="纳税识别号" name="invoiceTaxpayerNumber" placeholder="请输入纳税识别号"/>				</div>				<div>				</div>			</div>';
					$("#createPickup4 .invoiceInfo1").html(str);
				}
				
			});
			
			$("#createPickup4").on("change", "input[name=others]", function(){
				var $this = $(this);
				if (!isNaN($this.parents("tr").find("input[name=bulkstockAmounts]").val()) && !isNaN($this.parents("tr").find("input[name=interests]").html()) && !isNaN($this.parents("tr").find("input[name=others]").html())) {
					$this.parents("tr").find(".pickupAmount").html($this.parents("tr").find("input[name=interests]").val()*1 + $this.parents("tr").find("input[name=others]").val()*1 + $this.parents("tr").find("input[name=bulkstockAmounts]").val()*1);
					$this.parents("tr").find("input[name=pickupAmounts]").val($this.parents("tr").find("input[name=interests]").val()*1 + $this.parents("tr").find("input[name=others]").val()*1 + $this.parents("tr").find("input[name=bulkstockAmounts]").val()*1);
				}
			});
			
			$("#createPickup4").on("change", "input[name=interests]", function(){
				var $this = $(this);
				if (!isNaN($this.parents("tr").find("input[name=bulkstockAmounts]").val()) && !isNaN($this.parents("tr").find("input[name=interests]").html()) && !isNaN($this.parents("tr").find("input[name=others]").html())) {
					$this.parents("tr").find(".pickupAmount").html($this.parents("tr").find("input[name=interests]").val()*1 + $this.parents("tr").find("input[name=others]").val()*1 + $this.parents("tr").find("input[name=bulkstockAmounts]").val()*1);
					$this.parents("tr").find("input[name=pickupAmounts]").val($this.parents("tr").find("input[name=interests]").val()*1 + $this.parents("tr").find("input[name=others]").val()*1 + $this.parents("tr").find("input[name=bulkstockAmounts]").val()*1);
				}
			});
			
			$("#createPickup4").on("change", "input[name=bulkstockAmounts]", function(){
				var $this = $(this);
				if (!isNaN($this.parents("tr").find("input[name=bulkstockAmounts]").val()) && !isNaN($this.parents("tr").find("input[name=interests]").html()) && !isNaN($this.parents("tr").find("input[name=others]").html())) {
					$this.parents("tr").find(".pickupAmount").html($this.parents("tr").find("input[name=interests]").val()*1 + $this.parents("tr").find("input[name=others]").val()*1 + $this.parents("tr").find("input[name=bulkstockAmounts]").val()*1);
					$this.parents("tr").find("input[name=pickupAmounts]").val($this.parents("tr").find("input[name=interests]").val()*1 + $this.parents("tr").find("input[name=others]").val()*1 + $this.parents("tr").find("input[name=bulkstockAmounts]").val()*1);
				}
			});
			
			$("#createPickup4 .commonlyInfo").unbind("click").click(function(){
				var ii = layer.open({
				  title: '常用信息',
				  type: 1,
				  skin: 'layui-layer-rim', //加上边框
				  area: ['1000px', '650px'], //宽高
				  content: html_commonlyInfo,
				  btn: ['确定', '取消'],
				  yes: function(){
					databind.fillForm($("#createPickup4 .invoiceInfo"), ds[$(".html_commonlyInfo input[name=selected]:checked").parents("tr").attr("index")]);
					$("#createPickup4 input[name=buyer]").val(enterpriseName);
					layer.close(ii);
				  }
				});
				
				var oData = {
					pageIndex: pageIndex,
					pageSize: pageSize,
					totalPageCount: 0
				};
				
				$(".html_commonlyInfo .search").unbind("click").click(function(){
					oData = {
						pageIndex: pageIndex,
						pageSize: pageSize,
						totalPageCount: 0,
						invoiceEnterpriseName: $(".html_commonlyInfo input[name]").val()
					};
					tools.loadList("inquireEnterpriseInvoiceInfoPageList.json", $(".html_commonlyInfo .dataBody"), $(".html_commonlyInfo .dataTpl"), oData, function(data){
						ds = data.datas;
					}, $(".html_commonlyInfo .pagerCon"));
				});
				
				tools.loadList("inquireEnterpriseInvoiceInfoPageList.json", $(".html_commonlyInfo .dataBody"), $(".html_commonlyInfo .dataTpl"), oData, function(data){
					ds = data.datas;
				}, $(".html_commonlyInfo .pagerCon"));
			});
			
//			tools.loadSelectList($("#createPickup4 select[name=enterpriseId]"), "inquireEnterpriseList.json", "id", "name", null);
			
			$("#createPickup4 .addBulkstockInfo").unbind("click").click(function(){
				var ii = layer.open({
				  title: '添加货物信息',
				  type: 1,
				  skin: 'layui-layer-rim', //加上边框
				  area: ['1000px', '600px'], //宽高
				  content: html_bulkstockInfo,
				  btn: ['确定', '取消'],
				  yes: function(){
				  	if ($(".html_bulkstockInfo .check:checked").length > 0) {
				  	 	var i = 1;
					  	$.each($(".html_bulkstockInfo .check:checked"), function() {
					  		var $this = $(this);
					  		var tr = $(this).parents("tr").clone();
					  		tr.find(".check").parent().remove();
					  		tr.find(".index").html(i);													  		
					  		tr.find("input[name=pickupQuantitys]").parent().append(tr.find("input[name=pickupQuantitys]").val());
					  		tr.find(".pickupAmount").parent().append("<input type='hidden' name='pickupAmounts'/>");					  		
					  		$("#createPickup4 .table").append(tr);
					  		i++;
					  	});
					  	layer.close(ii);
				  	} else {
						base.alert(2, "请选择货物！");
					}
				  	
				  	tools.clearNoNumAll($("#createPickup4"));
				  	
				  	if ($("#createPickup4 .table tr").length > 1) {
						$("#createPickup4 select[name=enterpriseId]").attr("disabled", "disabled");
					} else {
						$("#createPickup4 select[name=enterpriseId]").removeAttr("disabled");
					}
				  }
				});
				
				tools.loadSelectList($(".html_bulkstockInfo select[name=bulkstockInfoId]"), "inquireBulkstockPageList.json?pageSize=1000", "bulkstockInfoId", "bulkstockName", "specificationName");
				tools.loadSelectList($(".html_bulkstockInfo select[name=warehouseName]"), "inquireWarehouseList.json?enterpriseId=" + enterpriseId, "text", "text", null);
				$(".html_bulkstockInfo span[name=enterpriseName]").html(enterpriseName);
				$(".html_bulkstockInfo input[name=enterpriseId]").val(enterpriseId);
				$(".html_bulkstockInfo select[name=productType]").val(productTypes);
				$(".html_bulkstockInfo input[name=financeNumber]").val(financeNumber);
				
//				tools.loadSelectList($(".html_bulkstockInfo select[name=bulkstockInfoId]"), "inquireBulkstockPageList.json?pageSize=1000", "bulkstockInfoId", "bulkstockName", "specificationName");
//				tools.loadSelectList($(".html_bulkstockInfo select[name=warehouseName]"), "inquireWarehouseList.json?enterpriseId=" + $("#createPickup4 select[name=enterpriseId]").val(), "text", "text", null);
//				$(".html_bulkstockInfo span[name=enterpriseName]").html($("#createPickup4 select[name=enterpriseId] option:selected").text());
//				$(".html_bulkstockInfo input[name=financeNumber]").html($("#createPickup4 input[name=financeNumber]").text()); 
//				$(".html_bulkstockInfo input[name=enterpriseId]").val($("#createPickup4 select[name=enterpriseId]").val());
//				$(".html_bulkstockInfo select[name=productType]").val(productTypes);
				
				

				$(".html_bulkstockInfo .search").unbind("click").click(function(){
					databind.submitDom($(".html_bulkstockInfo"), function(data){
						juicer.register("getValueByKey", constant.getValueByKey);
						var tpl = $(".html_bulkstockInfo .dataTpl").html();
						var html = juicer(tpl, data);
						$(".html_bulkstockInfo .dataBody").html(html);
						
						$.each($(".html_bulkstockInfo .check"), function() {
							var $this1 = $(this).parents("tr");
							$.each($("#createPickup4 table tr"), function(){
								var $this2 = $(this);
								if (($this1.find("input[name=locationIds]").val() != null && $this2.find("input[name=locationIds]").val() != null) && $this1.find("input[name=locationIds]").val() == $this2.find("input[name=locationIds]").val()) {
									if (($this1.find("input[name=financeIds]").val() != null && $this2.find("input[name=financeIds]").val() != null) && $this1.find("input[name=financeIds]").val() == $this2.find("input[name=financeIds]").val()) {
										$this1.find("input").attr("disabled", "disabled");
									}
								}
							});
						});
					});
				});
				
			});
			
			$("#createPickup4").on("click", ".delete", function(){
				$(this).parents("tr").remove();
				
				if ($("#createPickup4 .table tr").length > 1) {
					$("#createPickup4 select[name=enterpriseId]").attr("disabled", "disabled");
				} else {
					$("#createPickup4 select[name=enterpriseId]").removeAttr("disabled");
				}
			});
			
			tools.fileupload($("#createPickup4 #createPickup4FilesUuid"), null, function(data){
				var str = '<span class="showFiles"><a target="_blank" class="mas" fileUuid="' + data.result.data[0].fileUuid + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + data.result.data[0].fileUuid + '" class="showProductIntro">' + data.result.data[0].fileName + '</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="removeFile">x</a></span>';
				$("#createPickup4 .addfile").before(str);
				var fs = [];
				$.each($('#createPickup4 .mas'), function() {
					fs.push($(this).attr("fileUuid"));
				});
				$("#createPickup4 input[name=filesUuid]").val(fs);
			});
			
			$("#createPickup4").on("click", ".removeFile", function(){
				$(this).parents(".showFiles").remove();
				var fs = [];
				$.each($('#createPickup4 .mas'), function() {
					fs.push($(this).attr("fileUuid"));
				});
				$("#createPickup4 input[name=filesUuid]").val(fs);
			});
			
			//提交
			$("#createPickup4 .sure").unbind("click").click(function(){
				$("#createPickup4 input[name=enterpriseId]").val(enterpriseId);
				if ($("#createPickup4 table tr").length > 1) {
					databind.submitDom($("#createPickup4"), function(){
						base.alert(1, "提交成功!");
						router.route("account/warehousePickupList2.html?financeId=" + financeId);
					});
				} else {
					base.alert(2, "请先添加提货货物！");
				}
			});
			
			//取消
//			$("#createPickup4 .cancel_s1").unbind("click").click(function(){
//				router.route("account/warehousePickupList2.html?financeId=" + financeId);
//			});
			
			//融资证明材料
			$(".accountMaterial").unbind("click").click(function() {
				router.route("account/accountDetailMaterial.html?financeId=" + financeId + "&type="+productTypes);
			});

			//融资动态
			$(".accountProcess").unbind("click").click(function() {
				router.route("account/accountDetailProcess.html?financeId=" + financeId + "&type="+productTypes);
			});

			//提货列表
			$(".warehousePickups").unbind("click").click(function() {
				router.route("account/warehousePickupList2.html?financeId=" + financeId + "&type="+productTypes);
			});
			//融资项目信息
			$(".accountDetail").unbind("click").click(function(){
				router.route("account/accountDetail.html?financeId="+financeId + "&type="+productTypes);
			});
			
		};
		
		 //提交融资申请
		var submitFinanceApplication = function() {
			base.fnAjax({
				action: "submitFinanceApplication.json",
				async: false,
				oData: {
					financeId: financeId
				}, //传递参数
				fnSuccess: function(data) {
					if (data.status == 200) {
						router.route("account/accountMain.html");
					} else {
						base.alert(2, data.message);
					}
				}
			});
		};
		
		//取消融资申请
		var cancelFinanceApplication = function() {
			base.fnAjax({
				action: "cancelFinanceApplication.json",
				async: false,
				oData: {
					financeId: financeId
				}, //传递参数
				fnSuccess: function(data) {
					if (data.status == 200) {
						base.alert(1, "操作成功！");
						dialog.hideDialog($("#applyVerify"));
						router.route("account/accountMain.html");
					} else {
						base.alert(3, data.message);
					}
				}
			});
		};
		//查询评价信息
		var inquireFinanceEvaluate = function() {
			base.fnAjax({
				action: "inquireFinanceEvaluate.json",
				async: false,
				oData: {
					financeId: financeId
				}, //传递参数
				fnSuccess: function(data) {
					if (data.status == 200) {
						if (data.datas[0].content == "") {
							$(".buttonOperate").html("评价").attr("id", "evalute");
						} else {
							$(".buttonOperate").remove();
						}
					} else {
						$(".buttonOperate").html("评价").attr("id", "evalute");
						//                  base.alert(2,"信息获取失败");
					}
				}
			});
		};

		//货物一览
		var bulkstockListing = function() {
			router.route("account/accountBulkstockListing.html?financeId=" + financeId);
		}
		//融资评价
		var evaluteFinanceApplication = function() {
			router.route("account/accountEvaluate.html?financeId=" + financeId);
		}
		//合同一览
		var documentSign = function() {
			router.route("account/documentSign.html?financeId=" + financeId+"&financeState="+financeState);
		}
		var showEvaluteDetail = function(){
			router.route("account/accountEvaluateDetail.html?financeId="+financeId);
		}
		//额度处理
		var verifyFinanceApplication = function() {
			$("#popdialog").html(html_verify);
			dialog.showDialog($("#applyVerify"));
			$(".financeNumber").html(financeNumber);
			$(".financeAmount").html("￥" + financeAmount);

			databind.fillInput($("#applyVerify"), {
				action: "inquireCurrentEnterpriseDetail.json",
				version: "v1.0"
			});
			$("#verifySure").unbind("click").click(function() {
				consentFinanceAuditAmountApplication();
			});

			$("#verifyCancel").unbind("click").click(function() {
				cancelFinanceApplication();
			});
		}

		//接受融资审批金额
		var consentFinanceAuditAmountApplication = function() {
			base.fnAjax({
				action: "consentFinanceAuditAmountApplication.json",
				async: false,
				oData: {
					financeId: financeId
				},
				fnSuccess: function(data) {
					tools.cancelProtectDoubleClick();
					if (data.status == 200) {
						base.alert(1, "操作成功！");
						dialog.hideDialog($("#applyVerify"));
						router.route("account/accountMain.html");
					} else {
						base.alert(2, "数据获取失败");
					}
				}
			});
		};
		//提货申请
		var pickupFinanceApplication = function() {
			router.route("account/accountPickup.html?financeId=" + financeId + "&financeNumber=" + financeNumber);
		}
		//修改融资申请
		var updateFinanceApplication = function() {
			location.href = "../apply/apply_main.html?financeId=" + financeId + "&productType=" + productType;
		}
		
		//查询企业详情
//		var inquireFinanceApplicationDetail = function() {
//			base.fnAjax({
//				action: "inquireCurrentEnterpriseDetail.json",
//				nocode: true,
//				oData: {
//				
//				}, //传递参数
//				fnSuccess: function(data) {
//					if (data.status == 200) {
//						enterpriseName = data.datas[0].enterpriseName;	
////						$("#createPickup4 input[name=buyer]").val(data.datas[0].enterpriseName);
//						$("#createPickup4 select[name=enterpriseId]").val(data.datas[0].enterpriseId);
//					}else {
//						//
//					}
//				}
//			})
//		};
		//查询融资信息详情
		var inquireFinanceApplicationDetail_s2 = function() {
			base.fnAjax({
				action: "inquireFinanceApplicationDetail.json",//inquireFinanceApplicationList
				async: false,
				oData: {
					financeId: financeId
				}, //传递参数
				fnSuccess: function(data) {
					if (data.status == 200) {
						juicer.register("formatCurrency", tools.formatCurrency);
						juicer.register("getValueByKey", constant.getValueByKey);
						if (data.datas[0].productId != null && data.datas[0].productId != 0) {
							data.datas[0].bailRate = inquireFinanceProductDetail(data.datas[0].productId);
						}
						financeState = data.datas[0].financeState;
						enterpriseId=data.datas[0].enterpriseId;
						enterpriseName=data.datas[0].enterpriseName;
						productType=data.datas[0].productType;
						financeNumber=data.datas[0].financeNumber;
						financeAmount=data.datas[0].financeAmount;
//						if(productType == 2){
//							if (financeState == 1) {
//								
//							} else if (financeState == 2) {
//								$(".buttonOperate5").html("额度处理").attr("id", "verifyApply5").removeClass("none");
//								$(".buttonOperate5:first").before('<a class="buttonOperate5" id="cancelApply5">取消申请</a>');
//							} else if (financeState == 4) {
//								$(".buttonOperate5").html("修改").attr("id", "modifyApply5").removeClass("none");
//								$(".buttonOperate5:first").before('<a class="buttonOperate5" id="cancelApply5">取消申请</a>');
//							} else if (financeState == 17) {
//								inquireFinanceEvaluate();
//							} else if (financeState == 18) {
//								$(".buttonOperate5").html("评价").attr("id", "evalute5").removeClass("none");
//							} else if (financeState == 19) {
//								$(".buttonOperate5").html("评价信息").attr("id", "evaluteDetail5").removeClass("none");
//							} else if (financeState == 20) {
//								$(".buttonOperate5").html("取消申请").attr("id", "cancelApply5").removeClass("none");
//								$(".buttonOperate5:first").before('<a class="buttonOperate5" id="modifyApply5">修改</a>');
//								$(".buttonOperate5:first").before('<a class="buttonOperate5" id="submitApply5">提交融资</a>');
//							} else {
//								$(".buttonOperate5").hide();
//							}
//							
//							if (data.datas[0].bail - data.datas[0].bailAlreadyReturn > 0) {
//								$(".buttonOperate5:first").before('<a class="buttonOperate5" id="bailReturn5">退还保证金</a>');
//							}
//							if (financeState > 5) {
//								$(".buttonOperate5:first").before('<a class="buttonOperate5" id="bulkstockListing5">货物一览</a>');
//							}
//							if (financeState == 24 || financeState == 23 || financeState == 22) {
//								$(".buttonOperate5:first").before('<a class="buttonOperate5" id="documentSign5">合同签署</a>');
//							}
//		
//							if (financeState >= 6) {
//								$(".exceptionOperate").removeClass("none");
//								$(".buttonOperate5:first").before('<a class="buttonOperate5" id="pickupApply5">申请提货</a>');
//							}
//						}else 
						if(productType == 6){
//							if (data.datas[0].bail - data.datas[0].bailAlreadyReturn > 0) {
//								$(".buttonOperate5:first").before('<a class="buttonOperate5" id="bailReturn5">退还保证金</a>');
//							}
//							if (financeState > 5) {
//								$(".buttonOperate5:first").before('<a class="buttonOperate5" id="bulkstockListing5">货物一览</a>');
//							}
//							if (financeState == 24 || financeState == 23 || financeState == 22) {
//								$(".buttonOperate5:first").before('<a class="buttonOperate5" id="documentSign5">合同签署</a>');
//							}
		
							$(".buttonOperate5:first").before('<a class="buttonOperate5" id="createPickups_5">提货</a>');
						}else if(productType == 5){
//							if (financeState > 5) {
//								$(".buttonOperate5:first").before('<a class="buttonOperate5" id="bulkstockListing5">货物一览</a>');
//							}
//							if (financeState == 24 || financeState == 23 || financeState == 22) {
//								$(".buttonOperate5:first").before('<a class="buttonOperate5" id="documentSign5">合同签署</a>');
//							}
		
							$(".buttonOperate5:first").before('<a class="buttonOperate5" id="createPickups_5">提货</a>');
						}
						
//						$(".buttonOperate5:first").before('<a class="buttonOperate5" id="calcelApply5">融资申请取消</a>');
						
						databind.disableInput(".content2");
						$("#calcelApply5").unbind("click").click(function(){
							var ii = layer.open({
							  title: '融资取消申请',
							  type: 1,
							  skin: 'layui-layer-rim', //加上边框
							  area: ['800px', '300px'], //宽高
							  content: html_cancelApplication,
							  btn: ['确定', '取消'],
							  yes: function(){
							  	databind.submitDom($(".createFinanceCancelApplication"), function(){
							  		layer.msg("申请成功！");
							  		layer.close(ii);
							  		router.route("account/accountDetail.html?financeId=" + financeId);
							  	});
							  }
							});
							
							$(".createFinanceCancelApplication input[name=financeId]").val(financeId);
						});
						//取消融资
						$("#cancelApply5").unbind("click").click(function() {
							dialog.showConfirmDialog("取消融资", "是否确定取消融资？", function(){
								cancelFinanceApplication();
							});
						});
						//提交融资
						$("#submitApply5").unbind("click").click(function() {
							dialog.showConfirmDialog("提交融资", "提交以后不能再次修改,是否确定提交融资？", function(){
								submitFinanceApplication();
							});
						});
						
						$("#verifyApply5").unbind("click").click(function() {
							verifyFinanceApplication();
						});
						
						//修改融资
						$("#modifyApply5").unbind("click").click(function() {
							updateFinanceApplication();
						});
						//评价
						$("#evalute5").unbind("click").click(function() {
							evaluteFinanceApplication();
						});
						//货物一览
						$("#bulkstockListing5").unbind("click").click(function() {
							bulkstockListing();
						});
						//合同一览
						$("#documentSign5").unbind("click").click(function() {
							documentSign();
						});
						//保证金退还
						$("#bailReturn5").unbind("click").click(function() {
							var ii = layer.open({
							  title: '保证金退还',
							  type: 1,
							  skin: 'layui-layer-rim', //加上边框
							  area: ['300px', '150px'], //宽高
							  content: html_bailReturn,
							  btn: ['确定', '取消'],
							  yes: function(){
							  	databind.submitDom($(".createBailReturn"), function(){
							  		layer.msg("申请成功！");
							  		layer.close(ii);
							  	});
							  }
							});
							$(".createBailReturn input[name=financeId]").val(financeId);
							tools.clearNoNumAll($(".createBailReturn"));
						});
						//提货
						$("#createPickups_5").unbind("click").click(function(){
							if(productType == 5){
								router.route("account/createPickup6.html?enterpriseId=" + enterpriseId +"&financeNumber=" + financeNumber+"&enterpriseName="+enterpriseName+"&productType="+productType+"&financeId="+financeId);
							}else if(productType == 6){
								router.route("account/createPickup4.html?enterpriseId=" + enterpriseId +"&financeNumber=" + financeNumber+"&enterpriseName="+enterpriseName+"&productType="+productType+"&financeId="+financeId);
							}
							
						});
						//查看评价信息
						$("#evaluteDetail5").unbind("click").click(function() {
							showEvaluteDetail();
						});
						//提货申请
						$("#pickupApply5").unbind("click").click(function() {
							pickupFinanceApplication();
						});
					} else {}
				}
			});
		};
		
		return {
			init: init
		};
});